package lab03;

import java.io.*;

public class Test08 {
    public static void main(String[] args) throws IOException {


        FileInputStream file=new FileInputStream("E:\\test.txt");
        InputStreamReader reader=new InputStreamReader(file);
        BufferedReader  buffer=new BufferedReader(reader);

        FileInputStream file1=new FileInputStream("E:\\hello.txt");
        InputStreamReader reader1=new InputStreamReader(file1);
        BufferedReader  buffer1=new BufferedReader(reader1);

        FileOutputStream fo=new FileOutputStream("E:\\5.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fo);
        BufferedWriter bw=new BufferedWriter(osw);

        String line=buffer.readLine();
        String line1=buffer1.readLine();
        while(true)
        {
            if (line!=null&&line1!=null){
                System.out.println(line);
                System.out.println(line1);
                bw.write(line);
                bw.newLine();
                bw.write(line1);
                bw.newLine();
                bw.flush();
                line=buffer.readLine();
                line1=buffer1.readLine();
            }else if (line==null&&line1!=null){

                System.out.println(line1);

                bw.write(line1);
                bw.newLine();
                bw.flush();
                line1=buffer1.readLine();
            }else if (line!=null&&line1==null){
                System.out.println(line);

                bw.write(line);
                bw.newLine();
                bw.flush();
                line=buffer.readLine();

            }else{
                break;
            }

        }
    }
}
